/*
 * IkaAnim.h
 */

#ifndef IKAANIM_H_
#define IKAANIM_H_

#include<iostream>
#include<SFML/Graphics.hpp>
#include"IkaGraphic.h"
#include"IkaString.h"
#include"IkaArray.h"

namespace atomic {

/**
 * IkaAnim : a set of IkaGraphic in order to create an animation
 */
class IkaAnim {
public:

	/**
	 * Default constructor
	 */
	IkaAnim();

	/**
	 * Full constructor
	 *
	 * \param name		: name of the anim
	 * \param frames	: a vector containing IkaGraphics
	 * \param delay		: time between two frames (IkaGraphic)
	 * \param looped		: flag to know if this anim is looped
	 */
	IkaAnim(std::string name, std::vector<atomic::IkaGraphic> &frames,
			float delay = 0.2f, bool looped = false);

	/**
	 *  Another full constructor
	 *
	 * \param name				: name of the anim
	 * \param frameName	: the name of image to load for the first IkaGraphic
	 * \param delay				: time between two frames (IkaGraphic)
	 * \param looped				: flag to know if this anim is looped
	 *
	 */
	IkaAnim(std::string name, std::string frameName, float delay = 0.2f,
			bool looped = false);

	/**
	 * Constructor by copy
	 * \param  : an IkaAnim to copy
	 */
	IkaAnim(const atomic::IkaAnim &copy);

	/**
	 * Destructor
	 */
	virtual ~IkaAnim();

	/**
	 * Initialize attributes
	 */
	void Init();

	/**
	 * Add a frame (using his path) to the anim
	 * \param name : the path to the image
	 */
	void AddFrame(std::string name);

	/**
	 * Delete all frames of the anim
	 */
	void Clear();

	/**
	 * Access to a specific frame
	 * \param index : index of the frame to get
	 * \return an reference to the wanted IkaGraphic
	 */
	atomic::IkaGraphic& operator[](unsigned int index);

	/**
	 * Operator =
	 */
	atomic::IkaAnim& operator=(const atomic::IkaAnim & anim);

	/**
	 *  Access to a specific frame
	 * \param index : index of the frame to get
	 * \return an reference to the wanted IkaGraphic
	 */
	atomic::IkaGraphic& GetFrame(unsigned int index);

	/**
	 * Getter on the value of the 'loop' flag
	 * \return true if the anim could be played in loop mode
	 */
	bool Looped() const;

	/**
	 * Getter on the value of the delay between two frames
	 * \return the time between two frames (in sec)
	 */
	float Delay() const;

	/**
	 * Access to the whole vector of frames
	 * \return a std::vector<atomic::IkaGraphic>
	 */
	std::vector<atomic::IkaGraphic>& Frames();

	/**
	 * Access to the name of the anim
	 * \return the name of the anim
	 */
	std::string Name() const;

	/**
	 * Set the value of the flag 'loop'
	 * \param : a boolean
	 */
	void SetLooped(bool looped);

	/**
	 * Set the interval (in sec) between two frames
	 * \param : time in sec
	 */
	void SetDelay(float delay);

	/**
	 * Set a frame at a specific place of the vector of IkaAnim
	 * \param frames	: the new IkaGraphic to use
	 * \param index		: the index of this new frame
	 *
	 * \return true if the operation success
	 */
	bool SetFrame(const atomic::IkaGraphic &frames, unsigned int index);

	/**
	 * Set the name of the anim
	 */
	void SetName(std::string name);

protected:
	/**
	 * name of the anim
	 */
	std::string myName;

	/**
	 * delay between two frames
	 */
	float myDelay; // ms??

	/**
	 * vector containing IkaAnim frames
	 */
	std::vector<atomic::IkaGraphic> myFrames;

	/**
	 * the 'loop' flag
	 */
	bool isLooped;

};

}

#endif /* IKAANIM_H_ */
